<template>
	<view class="myInviteTeachers-page">
		<head-box></head-box>

		<view class="tab-botton">
				<cl-group :list="list" isType="2"></cl-group>
      <u-loadmore :status="status" :icon-type="iconType" @loadmore="loadmore" />
		</view>

		<tabs-box></tabs-box>
	</view>
</template>

<script>
  import {gpUserGpapplyList,gpGpinfo} from '@/api/group'
  import clGroup from '@/components/clGroup'
  import {getgpinfoapplyStatus} from '@/common/type'
	export default {
    components:{
      clGroup
    },
		data() {
			return {
        pageNo:1,//第几页
        pageSize:10,//每页条数
        search:'',//搜索相关内容
        status: 'loadmore', //加载的状态
        iconType: 'flower', //加载图标样式
        isLoading: false, //是否要加载数据
        pList:[],//其他数据
        list:[],//必要数据
			};
		},
		onLoad() {
			this.getList();
		},
    onShow(){
      // #ifdef H5
      console.log('分享')
      this.$wxSetShare()
      // #endif
    },
		methods:{
      loadmore(){
        this.pageNo++
        this.getList()
      },
      //审核状态
      getgpinfoapplyStatus(s){
        return getgpinfoapplyStatus(s)
      },
      //我的群团列表
			getList()
			{
        var that = this
        if (this.isLoading) {
          return
        }
        this.isLoading = true
        this.status = 'loading'
				const params = {"usergpinfoapplyStatus":"","column": "createTime","order": "desc",pageNo:this.pageNo,pageSize:this.pageSize}
				gpUserGpapplyList(params).then(res => {
          const {code,result:{records:list,total}}= res
          if(code===200){
            this.isLoading = false
            uni.hideLoading()
            if (!list.length) {
              this.status = 'nomore'
            } else {
              this.status = 'loadmore'
              this.pList =[... this.pList,...list]
              if (this.pList.length >= total) {
                this.status = 'nomore'
              }
              list.forEach(ele => {
                let n= {"usergpinfoapplyStatus":that.getgpinfoapplyStatus( ele.usergpinfoapplyStatus),"gpinfoName":"","gpinfoLogo":"","gpinfoIntroduce":"","createTime":ele.createTime,"usergpinfoapplyResult":ele.usergpinfoapplyResult}
                gpGpinfo(ele.gpinfoId).then(res => {
                  if(res.success)
                  {
                    n["gpinfoName"] = res.result.gpinfoName;
                    n["gpinfoLogo"] = res.result.gpinfoLogo;
                    n["gpinfoIntroduce"] = res.result.gpinfoIntroduce;

                  }
                });
                that.list.push(n);
              })
            }
          }
				});
			},
		},
    //加载到底部进行请求新的数据
    onReachBottom() {
      if (this.status === 'loadmore') {
        this.loadmore()
      }
    },
	}
</script>

